<? global $image_post_product,$product_id; ?>
<script language="javascript">

function TreeFilterChanged(value){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Browser does not support HTTP Request");
	  return;
	  } 
	var url="ajax/checkComp.php";
	url=url+"?id="+value;
	url=url+"&sid="+Math.random();
	url=url+"&comp=2";
	xmlHttp.onreadystatechange=ReadyTreeFilterChanged1;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}
function ReadyTreeFilterChanged1(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 	
		if(xmlHttp.responseText != "0"){		
			//location.href = "admin.php?do=image_post_products&act=list&cid="+xmlHttp.responseText;
			//document.getElementById('frmEdit').submit();
		}
		else{
			alert('Thể loại này không thể chứa sản phẩm');
		}
	}
}

function TreeFilterChanged1(value){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Browser does not support HTTP Request");
	  return;
	  } 
	var url="ajax/checkComp.php";
	url=url+"?id="+value;
	url=url+"&sid="+Math.random();
	url=url+"&comp=2";
	xmlHttp.onreadystatechange=ReadyTreeFilterChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}
function ReadyTreeFilterChanged(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 	
		if(xmlHttp.responseText != "0"){		
			if(FormIsValid())
				document.getElementById('frmEdit').submit();
		}
		else{
			alert('Thể loại này không thể chứa sản phẩm');
		}
	}
}

</script>
<script language="javascript">
function FormIsValid()
{
	var name_vn = document.getElementById("name_vn");
	var NameVNErrorMess = document.getElementById("NameVNErrorMess");
	var unique_key_vn = document.getElementById("unique_key_vn");
	var LinkVNErrorMess = document.getElementById("LinkVNErrorMess");
	
	FieldIsValidEqualFckEditorJS(name_vn, NameVNErrorMess);
	FieldIsValidEqualFckEditorJS(unique_key_vn, LinkVNErrorMess);
	
	return FieldIsValidEqualFckEditorJS(name_vn, NameVNErrorMess) && FieldIsValidEqualFckEditorJS(unique_key_vn, LinkVNErrorMess);
}
</script>

<form name="supplier" id="frmEdit" action="admin.php?do=image_post_product&act=<?php
			if($_GET['act'] == 'add')
				print('addsm');
			else
				print('editsm');
        	for($i = 0; $i < 6; $i++)
			{
					if(isset($image_post_product[$i]))
						echo "&pr".$i."=".$image_post_product[$i]['id'];
			}
			echo "&product_id=".$product_id;
			?>" method="post" enctype="multipart/form-data">
  <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr valign="top">
      <td><!-- start id-form -->
        <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
          <?
		  //echo "test";
          	//print_r($image_post_product);
		  ?>
          <?
          	for($i = 0; $i < 6; $i++)
			{
				
				$image_product = $image_post_product[$i];
		  ?>
          <tr>
            <th >Hình ảnh thứ [<?=$i+1?>]:</th>
            <td  width="120px"><?php
				if($_GET['act'] == 'edit' && $image_product['url'])
				{
				?>
              <img src="<?=$image_product['url']?>" width="100px"  /><br />
              <? } ?>
           </td>
           <td width="350px">   
              <input type="file" name="img_<?=($i)?>" class="file_1" size="50" /></td>
            <td ><div class="bubble-left"></div>
              <div class="bubble-inner">JPEG, GIF , JPG , PNG</div>
              <div class="bubble-right"></div></td>
          </tr>
          
          <?
          	}
		  ?>
          <tr>
            <th></th>
            <td><input type="submit" name="Submit"  value=" Save " class="form-submit" value=" Save " onclick="return true;" /></td>
            <td></td>
          </tr>
        </table>
        <!-- end id-form  --></td>
      <td><!--  start related-activities -->
        <div id="related-activities">
          <!--  start related-act-top -->
          <!-- end related-act-top -->
          <!--  start related-act-bottom -->
          <!-- end related-act-bottom -->
        </div>
        <!-- end related-activities --></td>
    </tr>
    <tr>
      <td><img src="images/shared/blank.gif" width="695" height="1" alt="blank" /></td>
      <td></td>
    </tr>
  </table>
  <div class="clear"></div>
</form>